package framework;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import framework.Browser.Browsers;

/**
 * Р С’Р В±РЎРѓРЎвЂљРЎР‚Р В°Р С”РЎвЂљР Р…РЎвЂ№Р в„– Р С”Р В»Р В°РЎРѓРЎРѓ, Р С•Р С—Р С�?РЎРѓРЎвЂ№Р Р†Р В°РЎР‹РЎвЂ°Р С�?Р в„– Р В±Р В°Р В·Р С•Р Р†РЎвЂ№Р в„– РЎвЂљР ВµРЎРѓРЎвЂљ Р С—РЎР‚Р С�?Р В»Р С•Р В¶Р ВµР Р…Р С�?РЎРЏ Р РЋР С•Р Т�?Р ВµРЎР‚Р В¶Р С�?РЎвЂљ Р С�Р ВµРЎвЂљР С•Р Т�?РЎвЂ№ Р Т�?Р В»РЎРЏ Р В»Р С•Р С–Р С�?РЎР‚Р С•Р Р†Р В°Р Р…Р С�?РЎРЏ Р С�? Р С—Р С•Р В»Р Вµ Р Р…Р В°РЎРѓРЎвЂљРЎР‚Р С•Р ВµР С” РЎвЂљР ВµРЎРѓРЎвЂљР В° (options)
 */
public abstract class BaseTestParam extends BaseEntity {

	@BeforeClass
	public void before() {
		browser = Browser.getInstance();
		browser.navigate(browser.getStartBrowserURL());
		logger.logTestName(this.getClass().getName());
	}

	/**
	 * for ie only
	 */
	public void acceptUnsignedSertificate() {
		if (Browser.currentBrowser == Browsers.IEXPLORE) {
			browser.navigate("javascript:document.getElementById('overridelink').click()");
		}
	}
	/** �?нициализирует входные данные.
	 */
	protected void initializeCreadentials(){
		String loginPart1 = System.getProperty(LOGIN_PART1) == null?props.getProperty(LOGIN_PART1):System.getProperty(LOGIN_PART1);
		String loginPart2 = System.getProperty(LOGIN_PART2) == null?props.getProperty(LOGIN_PART2):System.getProperty(LOGIN_PART2);
		String loginPartNotRegister = System.getProperty(LOGIN_PART_NOT_REGISTER) == null?props.getProperty(LOGIN_PART_NOT_REGISTER):System.getProperty(LOGIN_PART_NOT_REGISTER);
		String loginPartUnregUser = System.getProperty(LOGIN_PART_UNREGISTER_USER) == null?props.getProperty(LOGIN_PART_UNREGISTER_USER):System.getProperty(LOGIN_PART_UNREGISTER_USER);
		String password = System.getProperty(PASSWORD) == null?props.getProperty(PASSWORD):System.getProperty(PASSWORD);
		System.setProperty(LOGIN, loginPart1 + " " + loginPart2);
		System.setProperty(LOGIN_UNREG_ORG, loginPart1 + " " + loginPartNotRegister);
		System.setProperty(LOGIN_UNREGISTER_USER, loginPart1 + " " + loginPartUnregUser);
		System.setProperty(PASSWORD, password);
		// Логин и пароль для формы загрузки xml
		String loginUploadPart1 = System.getProperty(LOGIN_UPLOAD_PART1) == null?props.getProperty(LOGIN_UPLOAD_PART1):System.getProperty(LOGIN_UPLOAD_PART1);
		String loginUploadPart2 = System.getProperty(LOGIN_UPLOAD_PART2) == null?props.getProperty(LOGIN_UPLOAD_PART2):System.getProperty(LOGIN_UPLOAD_PART2);
		String uploadPassword = System.getProperty(UPLOAD_PASSWORD) == null?props.getProperty(UPLOAD_PASSWORD):System.getProperty(UPLOAD_PASSWORD);
		System.setProperty(LOGIN_UPLOAD, loginUploadPart1 + " " + loginUploadPart2);
		System.setProperty(UPLOAD_PASSWORD, uploadPassword);
		// Логин и пароль для входа в ЛК от имени загружающего XML
		String loginLoaderPart1 = System.getProperty(LOGIN_LOADER_PART1) == null?props.getProperty(LOGIN_LOADER_PART1):System.getProperty(LOGIN_LOADER_PART1);
		String loginLoaderPart2 = System.getProperty(LOGIN_LOADER_PART2) == null?props.getProperty(LOGIN_LOADER_PART2):System.getProperty(LOGIN_LOADER_PART2);
		String loaderPassword = System.getProperty(PASS_LOADER) == null?props.getProperty(PASS_LOADER):System.getProperty(PASS_LOADER);
		System.setProperty(LOGIN_LOADER, loginLoaderPart1 + " " + loginLoaderPart2);
		System.setProperty(PASS_LOADER, loaderPassword);
	}

/**
	 * Close browser after each test Class
	 */
	@AfterClass
	public void after() {
		//makeScreen(this.getClass());
		browser.exit();
		checkAndKill();
		try {
			logger.logTestEnd(this.getClass().getName());
		} catch (Exception e) {
		}
	}

	protected  String formatLogMsg(String message){
		return message;
	}

}
